;; EX-25.scm - Bottles (SC)

(synthdef-send
 (synthdef
  "bottle"
  ((freq 440))
  (let ((flute (Ringz.ar (Mul (EnvGen.kr envelope: (Env.perc 0.1)) 
			      (WhiteNoise.ar 0.02)) freq 0.3))
	(breath (Mul (EnvGen.kr envelope: (Env.perc) gate: 1.0) 
		     (Resonz.ar (PinkNoise.ar) (Add 5 (FDiv freq 2)) 0.1 2))))
    (let loop ((out flute) (n 0))
      (if (= n 2)
	  (let ((z (Mul (Add breath out)
			(EnvGen.kr envelope: (Env.linen 0.01 3.0 1.0) 
				   gate: 1.0 
				   doneAction: 2))))
	    (Out.ar 0 (list z z)))
	  (loop (Add out (AllpassN.ar 
			  out 0.1 (LinRand.ir 0.001 0.1 -1) 1.0 0.5)) 
		(+ n 1)))))))

(schedule-start)

(@ (lambda (pulse time)
     (-> "/s_new" "bottle" -1 1 1 "freq" (random 220 880))
     (random '(1/3 1/2 2/3 1))))
